# -1 倒数第一个
# a = [1,13,4,9]
# print(a[-1])

# a = [1,2,3,5,6,4,5,5]
# print(a.index(4))


#  count 计算多少个
# a = [1,2,3,5,6,4,5,5]
# print(a.count(5))

#数组切片 [start:end:step]
# a = [1,2,3,5,6,4,5,5]
# print(a[::-1])


#数组遍历1
# a =  [1,2,3,5,6,4,5,5]
# for idx in range(len(a)):
#     print(idx,a[idx])


#数组遍历2 枚举
# a = [1,2,3,5,6,4,5,5]
# for idx,value in enumerate(a):
#     print(idx,value)

# #数组遍历3 迭代器
# a = [1,2,3,5,6,4,5,5]
# for i in iter(a):
#     print(i)


#集合是否包含
str = "abc"
print('a' in str)
print('d' not in str)


#集合比较
# s1 = 'abc'
# s2 = 'ade'
# print(s2 > s1)
#
# a1 = [1,2,3]
# a2 = [2,3]
# print(a1 > a2)



#集合排序 sorted内建函数
# s1 = "145398"
# result = sorted(s1)
# print(result)

#元祖集合 默认是比较元祖的第一个
# s1 = [('sz0',14),('sz3',12),('sz5',20),('sz2',9),('sz8',15)]
# result = sorted(s1)
# print(result)


#元祖集合  通过传自定义回调函数getKey，实现比较元祖的第二个且倒序
# s1 = [('sz0',14),('sz3',12),('sz5',20),('sz2',9),('sz8',15)]
# def getKey(s):
#     return s[1]
# result = sorted(s1,key=getKey,reverse=True)
# print(result)


#列表方法sort，注意是针对列表， 字符串，元祖这些集合没有。
# s1 = [1,9,3,2,8]
# result = s1.sort(reverse=True)
# print(s1,result)

# 乱序 针对列表shuffle
# import random
# s = [1,2,3,4,5,6,7]
# result = random.shuffle(s)
# print(s,result)


#倒序
# s = ['h','e','l','l','o']
# result = s.reverse()
# print(result,s)

#数组切片 [start:end:step]
# a = [1,2,3,5,6,4,5,5]
# print(a[::-1])


































